var {
  clickContent,
  clickOneContent,
  randomUtils,
} = require("../../utils/index");
var { Action } = require("../../base/index");
var adYouShi = require("../../ads/youShi/index");

var aEatAction = new Action("吃饭补贴", {});

aEatAction.exec = function () {
  var content = "吃饭补贴";
  if (clickContent(content)) {
    sleep(randomUtils.getRandom(3, 5, 1000));
    var contents = ["看视频", "看广告"];
    if (clickOneContent(contents)) {
      sleep(randomUtils.getRandom(3, 5, 1000));
      adYouShi.startWatchAd();
      sleep(randomUtils.getRandom(3, 5, 1000));
      var contents = ["看视频", "看广告"];
      if (clickOneContent(contents)) {
        sleep(randomUtils.getRandom(3, 5, 1000));
        adYouShi.startWatchAd();
        sleep(randomUtils.getRandom(3, 5, 1000));
        this.goBack();
        return;
      }
      var contents = ["开心收下"];
      if (clickOneContent(contents)) {
        sleep(randomUtils.getRandom(3, 5, 1000));
        this.goBack();
        return;
      }
      this.goBack();
    }
  }
};
aEatAction.goBack = function () {
  back();
  sleep(randomUtils.getRandom(3, 5, 1000));
};

module.exports = aEatAction;
